package Collections.src.模拟斗地主升级版;

//import sun.reflect.generics.tree.Tree;

import java.util.*;

public class CollectionDemo02 {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<Integer, String>();
        ArrayList<Integer> array = new ArrayList<Integer>();
        String[] colors = {"♠", "♥", "♣", "🟥"};
        String[] numbers = {"2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K", "A"};
        int index = 0;
        for (String number : numbers) {
            for (String color : colors) {
                map.put(index, color + number);
                array.add(index);
                index++;
            }
        }

        map.put(index, "小王");
        array.add(index);
        index++;
        map.put(index, "大王");
        array.add(index);
        index++;

        //洗牌
        Collections.shuffle(array);

        //发牌
        TreeSet<Integer> jhxSet = new TreeSet<Integer>();
        TreeSet<Integer> hwjSet = new TreeSet<Integer>();
        TreeSet<Integer> djhSet = new TreeSet<Integer>();
        TreeSet<Integer> dpSet = new TreeSet<Integer>();

        for (int i = 0; i < array.size(); i++) {

            if (i >= array.size() - 3) {
                dpSet.add(i);
            } else if (i % 3 == 0) {
                jhxSet.add(i);
            } else if (i % 3 == 1) {
                hwjSet.add(i);
            } else if (i % 3 == 2) {
                djhSet.add(i);
            }
        }
        lookpoker("姜恒星",jhxSet,map);
        lookpoker("郝万杰",hwjSet,map);
        lookpoker("邓吉壕",djhSet,map);
        lookpoker("底牌",dpSet,map);


    }

    public static void lookpoker(String name, TreeSet<Integer> key, HashMap<Integer,String> map) {
        System.out.println(name+"的牌是");

        for (Integer KEY:key){
            String poker = map.get(KEY);
            System.out.print(poker+" ");
        }
        System.out.println();
    }

}
